package vip.xiaonuo.client.modular.goods;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.biz.modular.goods.entity.BizGoodsLedgerCheck;
import vip.xiaonuo.biz.modular.goods.param.ClientGoodsLedgerCheckParam;
import vip.xiaonuo.biz.modular.goods.param.ClientGoodsLedgerPageParam;
import vip.xiaonuo.biz.modular.goods.result.GoodsLedgerPageResult;
import vip.xiaonuo.biz.modular.goods.service.BizGoodsLedgerCheckService;
import vip.xiaonuo.biz.modular.goods.service.BizGoodsLedgerService;
import vip.xiaonuo.common.pojo.CommonResult;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 墨塵
 * @since 2022/12/8
 */
@Api(tags = "物品-台账记录")
@RestController
@Validated
public class ClientGoodsLedgerController {

    @Resource
    private BizGoodsLedgerService bizGoodsLedgerService;

    @Resource
    private BizGoodsLedgerCheckService bizGoodsLedgerCheckService;

    @ApiOperationSupport
    @ApiOperation("物品台账（分页）")
    @PostMapping("/client/goodsLedger/page")
    public CommonResult<Page<GoodsLedgerPageResult>> pageClientGoodsLedgerRecords(@RequestBody ClientGoodsLedgerPageParam param) {
        return CommonResult.data(bizGoodsLedgerService.pageClientGoodsLedgerRecords(param));
    }

    @ApiOperationSupport
    @ApiOperation("物品台账-检查项详情")
    @PostMapping("/client/goodsLedger/checkItems")
    public CommonResult<List<BizGoodsLedgerCheck>> listClientGoodsLedgerCheckItems(@RequestBody ClientGoodsLedgerCheckParam param) {
        return CommonResult.data(bizGoodsLedgerCheckService.getListByLedgerIdAndCheckType(param.getLedgerId(), param.getCheckType()));
    }
}
